cmake_minimum_required(VERSION 3.10)
project(dynamictextoverlay)

set(CMAKE_C_STANDARD 11)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")

# 查找必要的包
find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0)
pkg_check_modules(CAIRO REQUIRED cairo)
pkg_check_modules(PANGO REQUIRED pango)
pkg_check_modules(PANGO_CAIRO REQUIRED pangocairo)

# 设置插件名称和版本
set(PLUGIN_NAME "dynamictextoverlay")
set(PLUGIN_VERSION "1.0.0")

# 添加源文件
set(SOURCES
    gstdynamictextoverlay.c
)

# 创建共享库
add_library(${PLUGIN_NAME} SHARED ${SOURCES})

# 设置包含目录
target_include_directories(${PLUGIN_NAME} PRIVATE
    ${GSTREAMER_INCLUDE_DIRS}
    ${GSTREAMER_VIDEO_INCLUDE_DIRS}
    ${CAIRO_INCLUDE_DIRS}
    ${PANGO_INCLUDE_DIRS}
    ${PANGO_CAIRO_INCLUDE_DIRS}
)

# 链接库
target_link_libraries(${PLUGIN_NAME}
    ${GSTREAMER_LIBRARIES}
    ${GSTREAMER_VIDEO_LIBRARIES}
    ${CAIRO_LIBRARIES}
    ${PANGO_LIBRARIES}
    ${PANGO_CAIRO_LIBRARIES}
)

# 设置输出目录
set_target_properties(${PLUGIN_NAME} PROPERTIES
    PREFIX "libgst"
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/gstreamer-1.0"
)

# 安装规则
install(TARGETS ${PLUGIN_NAME}
    LIBRARY DESTINATION /usr/lib/x86_64-linux-gnu/gstreamer-1.0
)
